


package com.zdy.showgoods;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.example.networklibrary.model.ProductListModel;
import com.zdy.modellibrary.base.BaseActivity;
import com.zdy.utils.AppUtil;
import com.zdy.utils.GlideApp;
import com.zdy.utils.StringUtils;


public class ActivityGoodsInfo extends BaseActivity implements View.OnClickListener {
    private ImageView product_info_back;
    private ProductListModel productListModel;
    private ImageView product_info_img;
    private LinearLayout properties;
    private TextView product_statement;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_product_info);
        initView();
    }

    private void initView() {
        product_info_back = findViewById(R.id.product_info_back);
        product_info_back.setOnClickListener(this);

        product_info_img = findViewById(R.id.product_info_img);
        properties = findViewById(R.id.product_info_map);
        product_statement = findViewById(R.id.product_statement);
        productListModel = (ProductListModel) getIntent().getExtras().getSerializable("Item");
        product_statement.setText(StringUtils.returnString(productListModel.getSku_remark()));

        if(TextUtils.isEmpty(productListModel.getImage_id())){
            GlideApp.with(this).load(R.mipmap.img_test_3).into(product_info_img);

        }else {

            GlideApp.with(this).load(AppUtil.returnImgURL(this) + productListModel.getImage_id()).error(R.mipmap.img_test_3).into(product_info_img);
        }

        for (int i = 0; i < productListModel.getProperty_value_list().size(); i++) {
            View view = LayoutInflater.from(this).inflate(R.layout.item_property, null);
            TextView textView = view.findViewById(R.id.item_property_tv);
            textView.setText(productListModel.getProperty_value_list().get(i));
            properties.addView(textView);
        }
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.product_info_back) {
            finish();
        }
    }
}
